package com.aspose.cells;

class zayz {
   private static final com.aspose.cells.b.c.a.za a = new com.aspose.cells.b.c.a.za(new String[]{"OFFSET", ":"});

   static Object a(zbwm var0, zabd var1, Object var2, Object var3, Object var4, Workbook var5, Cell var6) {
      Object[] var7 = zba.a(new Object[]{var3, var4});
      int var8 = 0;
      int var9 = 0;
      Object[][] var10 = (Object[][])null;
      Object[][] var11 = (Object[][])null;
      if (var7[0] instanceof Object[][]) {
         var10 = (Object[][])((Object[][])var7[0]);
         var8 = var10.length;
         var9 = var10[0].length;
      }

      if (var7[1] instanceof Object[][]) {
         var11 = (Object[][])((Object[][])var7[0]);
         var8 = var11.length;
         var9 = var11[0].length;
      }

      Object[][] var12 = new Object[var8][];

      for(int var13 = 0; var13 < var8; ++var13) {
         var12[var13] = new Object[var9];

         for(int var14 = 0; var14 < var9; ++var14) {
            Object var15 = var10 == null ? var3 : (var10[var13] == null ? null : var10[var13][var14]);
            Object var16 = var11 == null ? var4 : (var11[var13] == null ? null : var11[var13][var14]);
            var12[var13][var14] = b(var0, var1, var2, var15, var16, var5, var6);
         }
      }

      return var12;
   }

   static Object b(zbwm var0, zabd var1, Object var2, Object var3, Object var4, Workbook var5, Cell var6) {
      var3 = zyn.a(var3, var5.getSettings());
      if (var3 != null && var3 instanceof zst) {
         return var3;
      } else {
         var4 = zyn.a(var4, var5.getSettings());
         if (var4 != null && var4 instanceof zst) {
            return var4;
         } else if (var3 instanceof Double && var4 instanceof Double) {
            int var11;
            if (!(var2 instanceof Object[][])) {
               if (var2 instanceof zft) {
                  zft var15 = (zft)var2;
                  Cells var17 = var5.getWorksheets().get(var15.b).getCells();
                  CellArea var18 = var15.d;
                  int var19 = (int)com.aspose.cells.a.c.zi.b(var3);
                  var11 = (int)com.aspose.cells.a.c.zi.b(var4);
                  int var12;
                  int var13;
                  Cell var23;
                  if (var19 == 0) {
                     boolean var20 = false;
                     boolean var22 = false;
                     if (var11 != 0) {
                        --var11;
                        var13 = var12 = var18.StartColumn + var11;
                     } else {
                        var12 = var18.StartColumn;
                        var13 = var18.EndColumn;
                     }

                     if (var12 > var18.EndColumn) {
                        return zst.g;
                     } else if (var18.StartRow == var18.EndRow) {
                        var23 = var17.checkCell(var18.StartRow, var12);
                        return var23 != null ? var0.a(var23) : null;
                     } else {
                        if (var1.c() != null) {
                           switch(a.a(var1.c().b())) {
                           case 0:
                              var18.StartColumn = var12;
                              var18.EndColumn = var13;
                              var15.d = var18;
                              return var15;
                           }
                        }

                        return var0.a(var1, var17.h(), var6, var18.StartRow, var18.EndRow, var12, var13, false, true);
                     }
                  } else if (var11 == 0) {
                     --var19;
                     var12 = var18.StartRow + var19;
                     if (var12 > var18.EndRow) {
                        return zst.g;
                     } else if (var18.StartColumn == var18.EndColumn) {
                        Cell var21 = var17.checkCell(var12, var18.StartColumn);
                        return var21 != null ? var0.a(var21) : null;
                     } else {
                        if (var1.c() != null) {
                           switch(a.a(var1.c().b())) {
                           case 0:
                              var18.StartRow = var12;
                              var18.EndRow = var12;
                              var15.d = var18;
                              return var15;
                           }
                        }

                        return var0.a(var1, var17.h(), var6, var12, var12, var18.StartColumn, var18.EndColumn, false);
                     }
                  } else {
                     --var19;
                     --var11;
                     if (var18.StartRow == var18.EndRow && var19 > 0) {
                        var11 = var19;
                        var19 = 0;
                     }

                     if (var18.StartRow + var19 <= var18.EndRow && var18.StartColumn + var11 <= var18.EndColumn) {
                        var12 = var18.StartRow + var19;
                        var13 = var18.StartColumn + var11;
                        if (var1.c() != null) {
                           String var14 = var1.c().b();
                           if ("()".equals(var14)) {
                              var14 = var1.c().c().b();
                           }

                           if (var14 != null) {
                              switch(a.a(var14)) {
                              case 0:
                              case 1:
                                 var18.StartRow = var18.EndRow = var12;
                                 var18.StartColumn = var18.EndColumn = var13;
                                 var15.d = var18;
                                 return var15;
                              }
                           }
                        }

                        var23 = var17.checkCell(var12, var13);
                        return var23 != null ? var0.a(var23) : null;
                     } else {
                        return zst.g;
                     }
                  }
               } else {
                  return (int)com.aspose.cells.a.c.zi.b(var3) == 1 && (int)com.aspose.cells.a.c.zi.b(var4) == 1 ? var2 : zst.g;
               }
            } else {
               Object[] var7 = (Object[])((Object[])var2);
               if (var7.length == 0) {
                  return zst.g;
               } else {
                  int var8 = (int)com.aspose.cells.a.c.zi.b(var3);
                  Object[] var9;
                  if (var8 != 0) {
                     --var8;
                     if (var8 > var7.length - 1) {
                        if (var7.length == 1) {
                           var9 = (Object[])((Object[])var7[0]);
                           if (var8 < var9.length) {
                              return var9[var8];
                           }
                        }

                        return zst.g;
                     } else if (var8 >= 0 && var8 <= var7.length) {
                        Object var16 = var7[var8];
                        var7 = (Object[])((Object[])var16);
                        var8 = (int)com.aspose.cells.a.c.zi.b(var4);
                        if (var8 == 0) {
                           return var7.length == 1 ? var7[0] : new Object[]{var7};
                        } else {
                           --var8;
                           return var8 > var7.length - 1 ? zst.g : var7[var8];
                        }
                     } else {
                        return zst.g;
                     }
                  } else {
                     var8 = (int)com.aspose.cells.a.c.zi.b(var4);
                     --var8;
                     var9 = (Object[])((Object[])var7[0]);
                     if (var8 > var9.length - 1) {
                        return zst.g;
                     } else if (var7.length == 1) {
                        return var9[var8];
                     } else {
                        Object[][] var10 = new Object[var7.length][];

                        for(var11 = 0; var11 < var7.length; ++var11) {
                           var9 = (Object[])((Object[])var7[var11]);
                           var10[var11] = new Object[]{var9[var8]};
                        }

                        return var10;
                     }
                  }
               }
            }
         } else {
            return zst.i;
         }
      }
   }
}
